package immutablecollections.functions;

import immutablecollections.*;

class FlipInvoker<O> extends Invoker<O>
{

    final private Invoker<O> meth;

    public FlipInvoker(Invoker<O> meth)
    {
        this.meth = meth;
    }

    @Override
    O invoke(ImList<Object> args)
    {
        return meth.invoke(args.reversed());
    }

    @Override
    String toString(ImList<Object> args)
    {
        return meth.toString(args) + " (with argument order flipped)";
    }

    @Override
    public String toString()
    {
        return toString((ImList<Object>) ImList.empty());
    }

}
